<extend name='Layout/page' />
<block name="content">
	{:widget('page_header/search',array('name'=>'站内消息','search'=>'M'))}
	<div class="operate-panel">
		
			
				<a class="btn" onclick="add()">发送消息</a>
			</div>
		</div>
	</div>
	<div class="frame">
		<div class="box col-12">
			<div class="ul-table">
				<hr>
				<if condition="!empty($list)">
					没找到数据
					<else/>
					<foreach name="list" val="vo">
						<div class="row">
							<div class="col-xs-1">
								<div class="user">
									<eq name="vo.sender_id" value="$owner_id">
										<img class="img-thumbnail" src="__ROOT__/{$vo.receiver_id|get_emp_pic}"  onerror="javascript:this.src='/Uploads/emp_pic/no_avatar.jpg'"/>
										<else/>
										<img class="img-thumbnail" src="__ROOT__/{$vo.sender_id|get_emp_pic}"  onerror="javascript:this.src='/Uploads/emp_pic/no_avatar.jpg'"/>
									</eq>
								</div>
							</div>
							<div class="col-xs-11">
								<div class="<gt name='vo.unread' value='0'>bold</gt>">
									<eq name="vo.sender_id" value="$owner_id">
										发给 {$vo.receiver_name}：<span>{$vo.create_time|to_date='Y-m-d H:i'}</span>
										<else/>
										{$vo.sender_name}：<span>{$vo.create_time|to_date='Y-m-d'}</span>
									</eq>
								</div>
								<div class="<gt name='vo.unread' value='0'>bold</gt>">
									{$vo.content}
								</div>
								<p>
									<span class="pull-right">
										<eq name="vo.sender_id" value="$owner_id">
											<a href="{:url('read','reply_id='.$vo['receiver_id'])}">共{$vo.count}条对话</a>
											<a onclick="reply_message({$vo.receiver_id})">回复</a>
											<a onclick="del_message({$vo.receiver_id})">删除</a>
											<else/>
											<a href="{:url('read','reply_id='.$vo['sender_id'])}">共{$vo.count}条对话</a>
											<a onclick="reply_message({$vo.sender_id})">回复</a>
											<a onclick="del_message({$vo.sender_id})">删除</a>
										</eq> </span>
								</p>
							</div>
						</div>
						<hr>
					</foreach>
					<div class="pagination">
						{$page}
					</div>
				</if>
			</div>
		</div>
	</div>
</block>

<block name="js">
	<script src="Public/layui/js/web_socket.js"></script>
	<script src="Public/layui/js/laychat.js"></script>
	<script type="text/javascript">
		layui.use(['element', 'global'], function() {
			var $ = layui.jquery;

			laychat.address = 'ws://' + document.domain + ':8282';
			// 置服务端websocket地址
			laychat.bindUrl = './chat/bind.php';
			// 将当前socket链接与用户绑定，并加入到对应群组（群组id可以自定）
			laychat.initUrl = './chat/init.php';
			// 初始化好友列表和群组接口，这个接口返回个json，格式见 http://www.layui.com/doc/modules/layim.html#init
			laychat.sendMessageUrl = './chat/send_message.php';
			// 发消息接口地址
			laychat.membersUrl = './chat/members.php';
			// 获取群成员接口地址
			laychat.uploadImageUrl = './chat/upload_img.php';
			// 上传图片接口地址
			laychat.uploadFileUrl = './chat/upload_file.php';
			// 上传文件接口地址
			laychat.chatLogUrl = './chat/chat_log.php';
			// 消息记录地址
			laychat.setMin = true;
			//最小化

			laychat.msgbox="{:url('Message/box')}";

			// 置服务端websocket地址
			laychat.bindUrl = '{:url("Chat/bind")}';
			laychat.initUrl = '{:url("Chat/init")}';
			laychat.sendMessageUrl = '{:url("Chat/send_message")}';
			laychat.membersUrl = '{:url("Chat/members")}';
			laychat.chatLogUrl = '{:url("Chat/chat_log")}';
			
			console.log(laychat);

			// 打开laychat对话框
			laychat.open();

		});
 
		// 消息记录地址
	</script>
</block>